<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateShareProductsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('share_products', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedInteger('member_id')->comment('用户id');
            $table->unsignedInteger('product_id')->comment('产品id');
            $table->unsignedBigInteger('order_id')->comment('订单id')->nullable();
            $table->smallInteger('product_commission_ratio')->comment('当时产品分拥金比例');
            $table->string('product_sku_name')->comment('购买的产品规格')->nullable();
            $table->smallInteger('amount')->comment('购买的产品规格数量')->default(0);
            $table->decimal('product_sku_price', 10 ,2)->comment('购买的产品价格')->default(0);
            $table->tinyInteger('status')->comment('1 待购买 2 已被购买')->default(1);
            $table->unsignedInteger('shared_id')->comment('购买者用户ID')->default(0);
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('share_products');
    }
}
